<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>农产品价格分析预测系统</title>
    <link rel="stylesheet" href="../static/css/index.css" />
    <script src="{{ url_for('static',filename='js/theme.js')}}"></script>
    <script src="{{ url_for('static',filename='js/echarts.min.js')}}"></script>
    <script src="../static/js/jquery.min.js"></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style2.css')}}">
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/formcss.css') }}">

</head>
<body style="margin: 0;">
    <div style="border-top: 50px solid #428bca;"></div>
    <div id="datetime" style="text-align: center; color: lightcyan; margin-top: -1.7%;margin-left: 5%;font-weight: bold;font-size:25px;"></div>

    <div style="text-align: center; color: white; font-size: 30px;margin-top: 30px;margin-left: 5%">产品分析</div>

    <script src="{{ url_for('static',filename='js/time.js')}}"></script>

    <!-- 侧边栏 -->
    <div class="sidebar">
    <div style="position: relative; border-top: 50px solid #428bca;">
        <div style="position: absolute; top: -40px; left: 0px; right: 0; text-align: center; color: white; font-size: 25px;">数据可视化</div>
    </div>
        <a href="/index" style="display: block; text-align: center; ">数据总览</a>
        <a href="/chart" style="display: block; text-align: center; ">产品分析</a>
        <a href="/chart1" style="display: block; text-align: center; ">价格变化趋势折线图</a>
        <a href="/chart2" style="display: block; text-align: center; ">价格变化情况滚动表</a>
        <a href="/chart3" style="display: block; text-align: center; ">价格变化柱状图</a>
        <a href="/chart4" style="display: block; text-align: center; ">价格对比雷达图</a>
        <a href="/chart5" style="display: block; text-align: center; ">最低价变化饼图</a>
        <a href="/predict" style="display: block; text-align: center; ">未来7日价格预测</a>
        <a href="/products" style="display: block; text-align: center; ">产品管理(管理员)</a>
        <a href="/manage" style="display: block; text-align: center; ">用户管理(管理员)</a>
        <a href="/register" style="display: block; text-align: center; ">用户注册</a>
        <a href="/login" style="display: block; text-align: center; ">切换用户</a>
</div>
    <center>
 <!-- 地图模块 -->
        <div class="map" style="width:90%;height:750px;margin-left: 5%;">
          <div class="map1"></div>
          <div class="map2"></div>
          <div class="map3"></div>
          <div class="chart"></div>
        </div>

    <!-- 农产品查询表单 -->
    <div style="text-align: center; bottom: 20px;  margin-left: 5%">
        <form id="form" name="form" method='POST' action='/chart' style="display: inline-block; text-align: left;">
            <h1 style="color: white;">请输入农产品名：
                <input type="text" name="product" placeholder="例：北方江米" style="height:50px;width:160px;font-size:25px;">
                <input type="submit" value="点击查询">
            </h1>
        </form>
    </div>

    </center>
        <div class="tablebox" style="height: 280px; width: 450px; margin-top: -400px; margin-left:43%;opacity: 0.7;">
            <div class="tbl-header">
                <table border="0" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th>日期</th>
                            <th>最低价(元)</th>
                            <th>最高价(元)</th>
                            <th>日均价(元)</th>
                        </tr>
                    </thead>
                    <tbody style="opacity:0;"></tbody>
                </table>
            </div>
            <div class="tbl-body">
                <table border="0" cellspacing="0" cellpadding="0">
                    <thead>
                        <tr>
                            <th>日期</th>
                            <th>最低价(元)</th>
                            <th>最高价(元)</th>
                            <th>日均价(元)</th>
                        </tr>
                    </thead>
                    <tbody ></tbody>
                </table>
            </div>
        </div>
    <script>
        $(document).ready(function() {
            var MyMarhq = '';
            clearInterval(MyMarhq);
            $('.tbl-body tbody').empty();
            $('.tbl-header tbody').empty();
            var str = '';
            var Items = {{dict_return['data_tb']|tojson}};
            $.each(Items, function (i, item) {
                str = '<tr>' +
                    '<td>' + item.date + '</td>' +
                    '<td>' + item.low_price + '</td>' +
                    '<td>' + item.high_price + '</td>' +
                    '<td>' + item.price + '</td>' +
                    '</tr>';
                $('.tbl-body tbody').append(str);
                $('.tbl-header tbody').append(str);
            });

            if (Items.length > 5) {
                $('.tbl-body tbody').html($('.tbl-body tbody').html() + $('.tbl-body tbody').html());
                $('.tbl-body').css('top', '0');
                var tblTop = 0;
                var speedhq = 50; // 数值越大越慢
                var outerHeight = $('.tbl-body tbody').find("tr").outerHeight();
                function Marqueehq() {
                    if (tblTop <= -outerHeight * Items.length) {
                        tblTop = 0;
                    } else {
                        tblTop -= 1;
                    }
                    $('.tbl-body').css('top', tblTop + 'px');
                }
                MyMarhq = setInterval(Marqueehq, speedhq);
                $(".tbl-header tbody").hover(function () {
                    clearInterval(MyMarhq);
                }, function () {
                    clearInterval(MyMarhq);
                    MyMarhq = setInterval(Marqueehq, speedhq);
                });
            }
        });
    </script>

    <script>
        var myChart = echarts.init(document.querySelector('.chart'), 'theme');
        myChart.setOption({
            textStyle: {
                color: 'rgba(255, 255, 255, 1)'
            },
            title: [
                { text: {{dict_return['n']|tojson}}+'最低价占比（日）', x: '22%', y: '3%', textAlign: 'center', textBaseline: 'middle', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { text: {{dict_return['n']|tojson}}+'三日最低价占比对比', x: '50%', y: '3%', textAlign: 'center', textBaseline: 'middle', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { text: {{dict_return['n']|tojson}}+'最低价变化', x: '78%', y: '3%', textAlign: 'center', textBaseline: 'middle', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { text: {{dict_return['n']|tojson}}+'最高价变化情况（日）', x: '16%', y: '50%', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { text: {{dict_return['n']|tojson}}+'价格变化情况滚动表', x: '45%', y: '53%', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { text: {{dict_return['n']|tojson}}+'日均价变化', x: '78%', y: '51%', textAlign: 'center', textBaseline: 'middle', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } },
                { x: '58%', y: '6%', textAlign: 'center', textBaseline: 'middle', textStyle: { fontSize: 18, color: 'rgba(255, 255, 255, 1)' } }
            ],
            legend: { top: '1%', orient: 'vertical', right: '0px', textStyle: { fontSize: 13, color: 'rgba(255, 255, 255, 1)' } },
            tooltip: { trigger: 'item', axisPointer: { type: 'cross' } },
            radar: [{
                indicator: {{dict_return['radar0']|tojson}},
                radius: 150,
                center: ['50%', '30%'],
                startAngle: 90,
                splitNumber: 6,
                shape: 'circle',
                name: { formatter: '【{value}】', textStyle: { color: '#428BD4' } },
                splitArea: { show: true, areaStyle: { color: ['#77EADF', '#26C3BE', '#64AFE9', '#26C3BE'], shadowColor: 'aqua', shadowBlur: 10 } },
                axisLine: { lineStyle: { color: 'rgba(255, 255, 255, 1)' } },
                splitLine: { show: true, lineStyle: { width: 1, color: '#286fbb' } }
            }],
            grid: [
                { left: '8%', right: '65%', top: '56%', bottom: '9%', containLabel: true },
                { gridindex: 1, left: '68%', right: '13%', top: '60%', bottom: '3%', containLabel: true },
                { gridindex: 2, left: '68%', right: '13%', top: '7%', bottom: '58%', containLabel: true }
            ],
            xAxis: [
                { type: 'category', data: {{dict_return['date']|tojson}}, axisLabel: { interval: 0, rotate: 0 } },
                { gridIndex: 1, type: 'category', boundaryGap: false, data: {{dict_return['date']|tojson}} },
                { gridIndex: 2, type: 'category', boundaryGap: false, data: {{dict_return['date']|tojson}} }
            ],
            yAxis: [
                { type: 'value', axisLabel: { formatter: '{value} ' }, boundaryGap: [0, 0.02] },
                { gridIndex: 1, type: 'value', axisLabel: { formatter: '{value} ' }, min: 2 },
                { gridIndex: 2, type: 'value', axisLabel: { formatter: '{value} ' } }
            ],
        dataZoom: [
            {
                type: 'slider',
                xAxisIndex: [0, 1,2],
                startValue: '2023-01-01'
            }
        ],
            series: [
                { name: '商品1', type: 'radar', tooltip: { trigger: 'item' }, label: { normal: { show: true, position: '', rotate: 0 } }, areaStyle: { color: "#FF00FF" }, data: {{dict_return['radar1']|tojson}} },
                { name: '商品2', type: 'radar', tooltip: { trigger: 'item' }, label: { normal: { show: true, position: '', rotate: 0 } }, areaStyle: { color: 'rgba(255, 228, 52, 0.6)' }, data: {{dict_return['radar2']|tojson}} },
                { name: '商品3', type: 'radar', tooltip: { trigger: 'item' }, areaStyle: { color: "#63B8FF" }, label: { normal: { show: true, position: '', rotate: 0 } }, data: {{dict_return['radar3']|tojson}} },
                { name: '最高价', type: 'bar', label: { normal: { show: true, position: '', rotate: 0 } }, showBackground: true, itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#83bff6' }, { offset: 0.5, color: '#188df0' }, { offset: 1, color: '#26C3BE' }]) }, emphasis: { itemStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#2378f7' }, { offset: 0.7, color: '#2378f7' }, { offset: 1, color: '#26C3BE' }]) } }, data: {{dict_return['high_price']|tojson}} },
                { name: '最低价', type: 'pie', radius: ['15%', '38%'], center: ['22%', '27%'], itemStyle: { borderRadius: 10, borderColor: '#fff', borderWidth: 2 }, label: { show: false, position: 'center' }, emphasis: { label: { show: true, fontSize: '18', fontWeight: 'bold' } }, labelLine: { show: true }, data: {{dict_return['data0']|tojson}} },
                { xAxisIndex: 1, yAxisIndex: 1, name: '日均价', type: 'line', lineStyle: { normal: { color: '' } }, data: {{dict_return['price']|tojson}}, smooth: true, markPoint: { data: [{ type: 'max', name: '最大值', symbolSize: 60 }, { type: 'min', name: '最小值', symbolSize: 60 }], itemStyle: { normal: { color: '#F36100' } } }, markLine: { data: [{ type: 'average', name: '平均值' }] } },
                { xAxisIndex: 2, yAxisIndex: 2, name: '最低价', type: 'line', lineStyle: { normal: { color: '#26C3BE' } }, data: {{dict_return['low_price']|tojson}}, smooth: true, markPoint: { data: [{ type: 'max', name: '最大值', symbolSize: 60 }, { type: 'min', name: '最小值', symbolSize: 60 }], itemStyle: { normal: { color: '#F36100' } } }, markLine: { data: [{ type: 'average', name: '平均值' }] } }
            ]
        });
            window.addEventListener('resize', myChart.resize);
    </script>

</body>
</html>
